package routers

import (
	"MBGAdmin/controllers/admin"
	"github.com/astaxie/beego"
)

// 后台
func init() {
	ns := beego.NewNamespace("/admin",
		// 登录、退出
		beego.NSRouter("/", &admin.LoginController{}, "get:Index"),
		beego.NSRouter("/login", &admin.LoginController{}),
		beego.NSRouter("/logout", &admin.LoginController{}, "get:Logout"),

		// 后台首页
		beego.NSNamespace("/index",
			beego.NSRouter("/index", &admin.IndexController{}),
			beego.NSRouter("/desktop", &admin.IndexController{}, "get:Desktop"),
			beego.NSRouter("/cache", &admin.IndexController{}, "get:CacheView;post:CacheClear"),
			beego.NSRouter("/password", &admin.IndexController{}, "get:PasswordView;post:UpdatePassword"),
		),

		// 管理员管理
		beego.NSNamespace("/admin",
			beego.NSRouter("index", &admin.AdminController{}),
			beego.NSRouter("lists", &admin.AdminController{}, "get:GetLists"),
			beego.NSRouter("delete/:id", &admin.AdminController{}, "post:Delete"),
			beego.NSRouter("create", &admin.AdminController{}, "get:CreateView;post:Create"),
			beego.NSRouter("update/:id", &admin.AdminController{}, "get:UpdateView;post:Update"),
		),

		// 角色管理
		beego.NSNamespace("/role",
			beego.NSRouter("index", &admin.RoleController{}),
			beego.NSRouter("lists", &admin.RoleController{}, "get:GetLists"),
			beego.NSRouter("delete/:id", &admin.RoleController{}, "post:Delete"),
			beego.NSRouter("create", &admin.RoleController{}, "get:CreateView;post:Create"),
			beego.NSRouter("update/:id", &admin.RoleController{}, "get:UpdateView;post:Update"),
		),

		// 菜单管理
		beego.NSNamespace("/menu",
			beego.NSRouter("index", &admin.MenuController{}),
			beego.NSRouter("lists", &admin.MenuController{}, "get:GetLists"),
			beego.NSRouter("delete/:id", &admin.MenuController{}, "post:Delete"),
			beego.NSRouter("create", &admin.MenuController{}, "get:CreateView;post:Create"),
			beego.NSRouter("update/:id", &admin.MenuController{}, "get:UpdateView;post:Update"),
		),

		// 系统设置
		beego.NSNamespace("/system",
			beego.NSRouter("index", &admin.SystemController{}),
			beego.NSRouter("save", &admin.SystemController{}, "post:Save"),
		),
	)

	beego.AddNamespace(ns)
}
